#include "MainWidget.h"
#include "./ui_MainWidget.h"

MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MainWidget)
{
    ui->setupUi(this);

    // 创建一个 QStringListModel
    QStringListModel *model = new QStringListModel(this);
    QStringList list;
    list << "Item 1 | Value 1" << "Item 2 | Value 2" << "Item 3 | Value 3" << "Item 4 | Value 4";
    model->setStringList(list);

    // 创建一个 QListView
    QListView *listView = new QListView(this);
    listView->setModel(model);

    // 设置自定义委托
    TwoColumnDelegate *delegate = new TwoColumnDelegate(this);
    listView->setItemDelegate(delegate);

    // 设置布局
    // QVBoxLayout *layout = new QVBoxLayout(this);
    // layout->addWidget(listView);
    // setLayout(layout);
}

MainWidget::~MainWidget()
{
    delete ui;
}
